<template>
    <addEditBaseTeacherView ref="addEditBaseTeacherView" />
    <addFileView ref="addFileView" />
    <el-main>
        <div class="teacher">
            <div class="app-table">
                <div class="app-body">
                        <el-form :inline="true" class="demo-form-inline" v-model="form">
                            <el-form-item label="姓名">
                                <el-input placeholder="请输入姓名" v-model="form.name"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <el-button class="serach_btn" type="primary" plain @click="onSubmit" @keyup.enter="searchEnter">搜索
                                </el-button>
                                <!-- <el-button type="success" plain @click="add">添加</el-button> -->
                                <!-- <el-button type="warning" plain @click="exportExcel">导出报表</el-button> -->
                                <!-- <el-button type="danger" plain @click="importExcel">批量导入<el-icon class="el-icon--right"> -->
                                        <!-- <Upload /> -->
                                    <!-- </el-icon> -->
                                <!-- </el-button> -->
                            </el-form-item>
                        </el-form>
                    <el-table size="default" :data="list" style="width: 100%" :row-class-name="tableRowClassName">
                        <el-table-column prop="id" label="id" width="100px" />
                        <el-table-column prop="teacherNumber" label="工号" />
                        <el-table-column prop="name" label="姓名" />
                        <!-- <el-table-column prop="sex" label="性别">
                            <template #default="scope">
                                {{scope.row.sex==1?'男':'女'}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="mobile" label="电话" />
                        <el-table-column prop="email" label="邮箱" />
                        <el-table-column prop="post" label="职务" /> -->

                        <!-- <el-table-column prop="address" label="地址"/>
                                <el-table-column prop="idCard" label="身份证号码"/>
                                <el-table-column prop="status" label="状态"/>
                                <el-table-column prop="password" label="密码"/>
                                <el-table-column prop="beforeName" label="曾用名"/>
                                <el-table-column prop="nationality" label="国籍"/>
                                <el-table-column prop="nation" label="民族"/>
                                <el-table-column prop="oneCardNumber" label="一卡通卡号"/>
                                <el-table-column prop="incomeDate" label="入党/团日期"/>
                                <el-table-column prop="politicalOutlook" label="政治面貌"/>
                                <el-table-column prop="photoUrl" label="个人照片"/>
                                <el-table-column prop="title" label="职称"/>
                                <el-table-column prop="compilationType" label="编制类型"/>
                                <el-table-column prop="maritalStatus" label="婚姻状态"/>
                                <el-table-column prop="personnelStatus" label="人员状态"/>
                                <el-table-column prop="personnelType" label="人员类型"/>
                                <el-table-column prop="educationLevel" label="教育程度"/>
                                <el-table-column prop="universityOneIsGraduated" label="毕业院校"/>
                                <el-table-column prop="majorStudied" label="所学专业"/>
                                <el-table-column prop="namePinyin" label="姓名拼音"/>
                                <el-table-column prop="renPing" label="拼音缩写"/>
                                <el-table-column prop="durationOfHeadTeacher" label="担任班主任年限"/>
                                <el-table-column prop="workYear" label="参加工作年月"/>
                                <el-table-column prop="interruptionOfWorklife" label="中断工作年限"/>
                                <el-table-column prop="beginningFromTeachingYears" label="开始从教年月"/>
                                <el-table-column prop="enteringUnitYear" label="进入单位年月"/>
                                <el-table-column prop="emergencyContactNumber" label="紧急联系电话"/>
                                <el-table-column prop="campus" label="校区、默认主校区"/>
                                <el-table-column prop="createDate" label="创建时间"/>
                                <el-table-column prop="isDelete" label="是否删除"/> -->
                        <el-table-column label="操作" width="220px">
                            <template style="display: block" #default="scope">
                                <!-- <el-button size="small" type="success" @click="editBaseTeacher(scope.row)">编辑
                                </el-button> -->
                                <el-button class="face_btn" size="small" type="warning" @click="editBaseTeacher(scope.row)">角色授权
                                </el-button>
                                <!-- <el-button size="small" type="danger" @click="deleteBaseTeacher(scope.row.id)">删除
                                </el-button> -->
                            </template>
                        </el-table-column>
                        <template v-slot:empty>
                            <el-empty description="暂无数据"></el-empty>
                        </template>
                    </el-table>
                    <el-config-provider :locale="locale">
                        <el-pagination :total="total" :page-size="limit" :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
                            layout="total, sizes, prev, pager, next, jumper" @size-change="changePageSize"
                            @current-change="changeCurrentPage">
                        </el-pagination>
                    </el-config-provider>
                </div>
                <bottomView></bottomView>
            </div>
        </div>
    </el-main>
</template>
<script>
import addEditBaseTeacherView from "@/components/baseInfo/addBaseTeacherRole.vue";
import addFileView from "@/components/addExcelFile.vue";
import { ElConfigProvider, ElMessageBox, ElMessage } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { httpService } from "@/utils/httpService";
import { Picture as IconPicture, Upload } from "@element-plus/icons-vue";
import bottomView from "@/components/bottom.vue";

export default {
    name: "BaseTeacherListView",
    data() {
        return {
            type: 0,
            title: "",
            page: 0,
            pageSize: 10,
            total: 0,
            limit: 10,
            list: [],
            form: {
                name: "",
                mobile: "",
                email: "",
                address: "",
                idCard: "",
                teacherNumber: "",
                password: "",
                beforeName: "",
                nationality: "",
                nation: "",
                oneCardNumber: "",
                politicalOutlook: "",
                photoUrl: "",
                post: "",
                title: "",
                compilationType: "",
                maritalStatus: "",
                personnelStatus: "",
                personnelType: "",
                educationLevel: "",
                universityOneIsGraduated: "",
                majorStudied: "",
                namePinyin: "",
                renPing: "",
                emergencyContactNumber: "",
            },
        };
    },
    components: {
        addEditBaseTeacherView,
        addFileView,
        IconPicture,
        ElConfigProvider,
        ElMessageBox,
        ElMessage, Upload,bottomView
    },
    setup() {
        return {
            locale: zhCn,
        };
    },
    mounted() {
        this.getBaseTeacherList();
    },
    watch: {
        $route() {
            this.getBaseTeacherList();
        },
    },
    methods: {
        searchEnter: function (e) {
            // 使用 which 和 keyCode 属性来解决兼容问题
            var keyCode = window.event ? e.keyCode : e.which;
            var val = e.target.value;
            if (keyCode == 13 && val) {
                this.getBaseTeacherList();
            }
        },
        add() {
            this.$refs.addEditBaseTeacherView.title = "添加人员信息"
            this.$refs.addEditBaseTeacherView.dialogFormVisible = true;
        },
        editBaseTeacher(obj) {
            this.$refs.addEditBaseTeacherView.title = "角色授权"
            this.$refs.addEditBaseTeacherView.getBasePermission(obj.id);
            this.$refs.addEditBaseTeacherView.dialogFormVisible = true;
        },
     
        reloadData() {
            this.page = 1;
            this.getBaseTeacherList()
        },
      
        onSubmit() {
            this.getBaseTeacherList();
        },
        // 每页记录数改变，size：回调参数，表示当前选中的“每页条数”
        changePageSize(size) {
            this.pageSize = size;
            this.limit = size;
            this.getBaseTeacherList();
        },

        // 改变页码，page：回调参数，表示当前选中的“页码”
        changeCurrentPage(page) {
            this.page = page;
            this.getBaseTeacherList();
        },
        tableRowClassName({ row, rowIndex }) {
            return "";
        },
        getBaseTeacherList() {
            httpService(
                "/javaApi/baseTeacher/list/" + this.page + "/" + this.pageSize,
                {
                    "name": this.form.name,
                    "mobile": this.form.mobile,
                },
                "get"
            ).then((data) => {
                this.list = data.list;
                this.total = data.total;
                this.pageCount = data.pages;
            });
        },
    },
};
</script>
<style scoped>
.el-main {
    padding: 0px;
}

.teacher-content {
    width: 100%;
}


.app-table {
    background: #EFEFEF;
    padding:5px 10px 10px;
}

.app-search {
    margin-top: 10px;

}

.app-separator {
    padding-top: 10px;
    padding-bottom: 20px;
    padding-left: 10px;
}

.app-body {
    background: white;
    padding: 20px 20px 10px 20px;
    margin-bottom: 10px;
    min-height: calc(100vh - 200px);
    text-align:left;

}

.el-table .warning-row {
    --el-table-tr-bg-color: var(--el-color-warning-lighter);
}

.el-table .success-row {
    --el-table-tr-bg-color: var(--el-color-success-lighter);
}

.el-pagination {
    text-align: center;
    margin-top: 10px;
}
.face_btn {
  background-color: #fff;
  color: #ff8400;
  border: none;
}
.serach_btn {
    background-color: #007EFF;
    color: #fff;
    border-radius: 8px;
    border: none;
}


</style>

